<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="constants.StringConstants" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/mystyle.css" rel="stylesheet" type="text/css">
<script src="js/edit-link.js"></script>
<script type="text/javascript">
function pick_food(id) {
	window.open("RecipeServlet?id="+ id ,"_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=200, width=400, height=400");
}
</script>
<title>Recipe maintain</title>
</head>
<body>
	<span style="float:left"><a href="/XMLProject/admin/admin-home.jsp">Go to Home</a></span><br/>
	<span style="float:right">
		Hi, <strong>${sessionScope.ADMIN_USERNAME}</strong>-
		<a href="AccountServlet?action=<%=StringConstants.LOGOUT%>">Logout</a>
	</span>
	<h2>Recipe Management</h2>
	
	<c:set var="list" value="${requestScope.RECIPELIST}"/>
	<c:if test="${not empty list}">
            <table border="1">
                <thead>
                    <tr>
                        <th>No.</th>
                        <th>Recipe Name</th>
                        <th>Add more dish</th>
                        <th>Change</th>
                        <th>Remove</th>
                    </tr>
                </thead>
                <tbody>
                <c:forEach var="recipeDTO" items="${list}" varStatus="counter">
                     <tr>
                        <td>${counter.count}</td>
                        <td>
                        	<form class="editForm" action="RecipeServlet" method="post">
                        		<input type="hidden" id="dishs_str" name="dishs_str"/>
                        		<input type="hidden" name="action" value="edit"/>
								<input type="hidden" name="id" value="${recipeDTO.id}"/>
								<input type="text" name="name" class="nameEdit" value="${recipeDTO.name}"/>
								<p class="error">Please input!!</p>
							</form>
                        </td>
                        <td>
                        	<a href="#" onclick="pick_food(${recipeDTO.id})">Add more</a>
                        </td>
                        <td>
							<a href="#" onclick="clickLinkEdit(this)">Change</a>
						</td>
						<td>
	                        <form method="POST" action="RecipeServlet">
							    <input type="hidden" name="action" value="delete">
							    <input type="hidden" name="id" value="${recipeDTO.id}">
							    <a href="#" onclick="clickLinkDelete(this)">Remove</a>
							</form>
						</td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
	</c:if>
	<hr/>
	<form action="RecipeServlet" method="post" onsubmit="return validateAdd()">
		<input type="text" id="name" name="name" class="nameEdit" value=""/>
		<p id="errorAdd" class="error">Please input!!</p>
		<input type="submit" name="action" value="add"/>
	</form>
	<hr/>
</body>
</html>